/**
 * Created by Administrator on 2015/4/24.
 */
var config = require('./config.json');
var ejs = require('ejs');
var fs=require('fs');

var cache = [];
var tempSql=config.template;

function Notification(key, user, lang, value) {
    this.key = key;
    this.lang = lang;
    this.value = value;
    this.user = user;
}

Notification.prototype.toString = function () {
    return ejs.render(tempSql, this);
};

config.locale.forEach(function (item, index) {
    var notifyEn = new Notification(item.key, config.user, 'En', item.en);
    var notifyCn = new Notification(item.key, config.user, 'ZhCn', item.cn);
    cache.push(notifyEn.toString(),notifyCn.toString());
});

fs.writeFile('./output/locale.sql',cache.join('\r\n'),'utf-8', function () {
   console.log('success');
});
